﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyRabbit.Application.Command.ImgCommand;
using MyRabbit.Application.Dtos;
using MyRabbit.Application.ErrorCode;

namespace MyRabbit.Web.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ImgController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator  mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public ImgController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 添加图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        //[HttpPost]
        //public async Task<APIResult<object>> ImgAdd(ImgAddCommand command)
        //{
        //    return await mediator.Send(command);
        //}


        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> ImgDel(ImgDelCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 显示查询
        /// </summary>
        /// <param name="elseId"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<ImgDTO>>> ImgQuery(int theRestId)
        {
            ImgQueryCommand command = new ImgQueryCommand();
            command.TheRestId = theRestId;
            return await mediator.Send(command);
        }



    }
}
